package com.help.help.service.impl;

import com.help.help.entity.UserEntity;
import com.help.help.service.UserService;
import io.netty.util.internal.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import com.help.help.dao.WithdrawDao;
import com.help.help.entity.WithdrawEntity;
import com.help.help.service.WithdrawService;


@Service("withdrawService")
public class WithdrawServiceImpl extends ServiceImpl<WithdrawDao, WithdrawEntity> implements WithdrawService {
    @Autowired
    private UserService userService;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<WithdrawEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if(!StringUtil.isNullOrEmpty(key)){
            wrapper.eq("uuid",key);
        }
        IPage<WithdrawEntity> page = this.page(
                new Query<WithdrawEntity>().getPage(params),
              wrapper
        );
        for (WithdrawEntity record : page.getRecords()) {
              record.setUser(userService.getById(record.getUserId()));
        }
        return new PageUtils(page);
    }

}